﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Ivy.Common.Framework.GeneralUtility;
using Ivy.SiteAdmin.Entity;
using Ivy.SiteAdmin.BusinessLogic;
using Ivy.SiteAdmin.IBusinessLogic;
using DasIdeen.ViewEntity;

namespace DasIdeen.UserControls
{
	public partial class ContactUsControl : System.Web.UI.UserControl
	{
        #region  Variable & constant
        public AntiSpamUtility antiSpam = new AntiSpamUtility();
        #endregion  Variable & constant

        #region Constructor & Destructor
        #endregion Constructor & Destructor

        #region Properties
        #endregion Properties

        #region Public Methods
        #endregion Public Methods

        #region Events
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                hidCorrectAnswer.Value = antiSpam.GenerateMathFormula();
                lblAntiSpam.Text = antiSpam.MathFormula;
            }

        }

        protected void btnSend_Click(object sender, EventArgs e)
        {
           try
           {
               if (txtAntiSpam.Text == hidCorrectAnswer.Value)
               {
                   ContactRequestRegister lContactRequestRegister = new ContactRequestRegister();
                   SiteAdminBus lSiteAdminBus = new SiteAdminBus();
                   lContactRequestRegister.ContactRequesterName = this.txtName.Text.Trim();
                   lContactRequestRegister.ContactRequesterEmail = this.txtEmailId.Text;
                   lContactRequestRegister.ContactRequestMessage = this.txtMessage.Text;

                   lContactRequestRegister.Sys_CreatedByID = this.txtName.Text;
                   lSiteAdminBus.RegisterNewContactRequest(lContactRequestRegister);
                   this.lblConfirmMesssage.Visible = true;
                   ClearScreen();
               }
               else
               {
                    hidCorrectAnswer.Value = antiSpam.GenerateMathFormula();
                    lblAntiSpam.Text = antiSpam.MathFormula;
               }
           }
           catch (Exception ex)
           {
               ExceptionUtility.ExceptionHandler(ex, Server.MapPath("~/"));
           }
        }
        #endregion Events

        #region Private Methods
        private void CheckUserAutherization()
        {
        }

        private void ClearScreen()
        {
            this.txtName.Text = string.Empty;
            this.txtEmailId.Text = string.Empty;
            this.txtMessage.Text = string.Empty;
            this.txtAntiSpam.Text = string.Empty;
        }

        private void InitializeScreen()
        {
            ClearScreen();
            FillLoadLookUpData();
        }

        private void FillLoadLookUpData()
        {
        }

        private void TranslateEntityToUIControls()
        {
        }

        private void TranslateUIControlsToEntity()
        {
        }
        #endregion Private Methods
		
	}
}